<template>
	<h1>项目管理</h1>
	<el-button v-auth="'user:add'" @click="clickHandler()">接口调用</el-button>
	<el-button @click="clickHandler2()">接口返回401</el-button>
	<el-button @click="clickHandler3()">退出登录</el-button>
</template>
<script setup lang="ts">
import { onMounted } from 'vue'
import { baseClassDetailApi } from '@/api/base-class'
import { _401Api } from '@/api/auth'
import { useUserStore } from '@/store/user-store'
import { router } from '@/router'

const userStore = useUserStore()

defineOptions({
	name: 'GenProject'
})

onMounted(() => {
	console.log('项目管理')
})

const clickHandler = () => {
	baseClassDetailApi(1).then(res => {
		console.log(res)
	})
}

const clickHandler2 = () => {
	_401Api().then(res => {
		console.log(res)
	})
}

const clickHandler3 = () => {
	userStore.clearAll()
	console.log('清空用户数据')
	console.log(userStore.userInfo)
	console.log(userStore.tokenInfo)
	router.push({
		path: '/login',
		query: {
			redirect: encodeURIComponent(router.currentRoute.value.fullPath || '/')
		}
	})
}
</script>
